/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "dal_cyclonedds/converter/StatusMaskConverter.hpp"

TEST(StatusMaskConverter, test_ConvertStatusMaskFromDalToCyclonedds)
{
    uint32_t mask;
    StatusMaskConverter::GetInstance()->ConvertStatusMaskFromDalToCyclonedds(DAL_SAMPLE_LOST_STATUS,
                                                                             &mask);
    EXPECT_EQ(mask, DDS_SAMPLE_LOST_STATUS);

    uint32_t cyclone_all_mask =
        DDS_INCONSISTENT_TOPIC_STATUS | DDS_OFFERED_DEADLINE_MISSED_STATUS |
        DDS_REQUESTED_DEADLINE_MISSED_STATUS | DDS_OFFERED_INCOMPATIBLE_QOS_STATUS |
        DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS | DDS_SAMPLE_LOST_STATUS |
        DDS_SAMPLE_REJECTED_STATUS | DDS_DATA_ON_READERS_STATUS | DDS_DATA_AVAILABLE_STATUS |
        DDS_LIVELINESS_LOST_STATUS | DDS_LIVELINESS_CHANGED_STATUS |
        DDS_PUBLICATION_MATCHED_STATUS | DDS_SUBSCRIPTION_MATCHED_STATUS;

    StatusMaskConverter::GetInstance()->ConvertStatusMaskFromDalToCyclonedds(DAL_ANY_STATUS, &mask);
    EXPECT_EQ(mask, cyclone_all_mask);

    StatusMaskConverter::GetInstance()->ConvertStatusMaskFromDalToCyclonedds(
        DAL_DATA_AVAILABLE_STATUS, &mask);
    EXPECT_EQ(mask, DDS_DATA_AVAILABLE_STATUS);
}
